import {useState,useEffect} from 'react'
import {useLocation,useNavigate,Outlet} from 'react-router-dom'
// import axios from 'axios'

import { Select ,Flex ,Button, Table,Space} from 'antd';
import type { TableColumnsType } from 'antd';
interface DataType {
    key:string,
    index:number,
    diagnosis:string,
    code:string,
    room: string,//开单科室
    doctor: string,//开单医生
    price: number,//金额
    psttype: string,//处方种类
    state: string,//状态
    prescription:object,
    createTime: string,//记录时间
  }
let premain = {
    width:'100%',
    height:'100%',
    borderRadius: 6,
    // border:'1px solid orange',
}
let pretop = {
    width:'100%',
    height:'50px',
    borderRadius: 6,
    // border:'1px solid blue',
}
let prebott = {
    width:'100%',
    height:'400px',
    borderRadius: 6,
    // border:'1px solid blue',
}
let pretplef = {
    width:'20%',
    height:'100%',
    borderRadius: 6,
    // border:'1px solid blue',
}
let pretprht = {
    width:'30%',
    height:'100%',
    borderRadius: 6,
    // border:'1px solid blue',
}

  
  const data: DataType[] = [
    {
        key:'0',
        index:0,
        diagnosis:'aa',
        code:'aab',
        room: 'a',
        doctor: 'xiaoming',
        price: 111,
        psttype: 'x',
        prescription: [Object],
        state: '0',
        createTime: '2000-11-11',
    },
    {
        key:'1',
        index:0,
        diagnosis:'aa',
        code:'aab',
        room: 'a',
        doctor: 'xiaoming',
        price: 111,
        psttype: 'x',
        prescription: [Object],
        state: '0',
        createTime: '2000-11-11',
    },
    {
        key:'2',
        index:0,
        diagnosis:'aa',
        code:'aab',
        room: 'a',
        doctor: 'xiaoming',
        price: 111,
        psttype: 'x',
        prescription: [Object],
        state: '0',
        createTime: '2000-11-11',
    },
    {
        key:'3',
        index:0,
        diagnosis:'aa',
        code:'aab',
        room: 'a',
        doctor: 'xiaoming',
        price: 111,
        psttype: 'x',
        prescription: [Object],
        state: '0',
        createTime: '2000-11-11',
    }
  ];
  

export default function prescription(){//处方
    let [tab,settab] = useState([
        {'id':0,'name':'新增西药处方','path':'/frame/studio/awg'},
        {'id':1,'name':'新增中药处方','path':'/frame/studio/awg'}
    ])
    const columns: TableColumnsType<DataType> = [
        {
          title: '序号',
          dataIndex: 'index',
        },
        {
          title: '处方号',
          dataIndex:'code',
        },
        {
          title: '开单科室',
          dataIndex: 'room',
        },
        {
            title: '开单医生',
            dataIndex: 'doctor',
        },
        {
            title: '金额',
            dataIndex: 'price',
        },
        {
            title: '处方种类',
            dataIndex: 'psttype',
        },
        {
            title: '状态',
            dataIndex: 'state',
        },
        {
            title: '记录时间',
            dataIndex: 'createTime',
        },
        {
            title: '操作',
            render: (_, record) => (
                <Space size="middle">
                  <a onClick={() => btn(record.key)}>编辑</a>
                  <a>删除</a>
                </Space>
            )
        },
      ];

    const handleChange = (value: string) => {
        console.log(`selected ${value}`);
    };
    let btn = (code:any)=>{
        alert(code)
    }

    let navigator = useNavigate()
    let btngo = (info:string)=>{
        navigator(info)
    }

    useEffect(()=>{

    },[])

    return (
        <>
            <Flex wrap style={premain}>
                <Flex justify='space-between' align='center' style={pretop}>
                    <Flex justify='space-around' align='center' style={pretplef}>
                        状态：<Select
                            defaultValue="全部状态"
                            style={{ width: 120 }}
                            onChange={handleChange}
                            options={[
                                { value: '全部状态', label: '全部状态' },
                                { value: '待审核', label: '待审核' },
                                { value: '已收费', label: '已收费'},
                                { value: '未收费', label: '未收费' }
                            ]}
                        />
                    </Flex>
                    <Flex justify='space-around' align='center' style={pretprht}>
                        {
                            tab.map((item)=>(
                                <Button onClick={()=>{btngo(item.path)}} type='primary' size='small' >{item.name}</Button>
                            ))
                        }
                    </Flex>
                </Flex>
                <Flex style={prebott}>
                    <Table<DataType> scroll={{ y:300}}  columns={columns} dataSource={data} pagination={false} size="middle" />
                </Flex>
            </Flex>
            
        </>
    )
}



